<template>
  <div>
    <div class="position">
      <div class="positionLeft">
        <div class="locationName">青年汇店</div>
        <div class="distance">据您53m</div>
      </div>
      <div class="positionRight">
        <div class="takingMethods1">自提</div>
        <div class="takingMethods2">外送</div>
      </div>
    </div>
    <div class="homeFunction">
      <router-link tag="li" to="category" class="homeOrder homefunc">
        <div class="hometext">
          <div class="homefuncleft">
            <div class="homefunctop">现在下单</div>
            <div class="homefuncbottom">ORDER NOW</div>
          </div>
          <div class="homefuncright">
            <van-icon class="iconfont" class-prefix="icon" name="kafei" />
          </div>
        </div>
      </router-link>
      <router-link tag="li" to="category" class="homeWallet homefunc">
        <div class="hometext">
          <div class="homefuncleft">
            <div class="homefunctop">咖啡钱包</div>
            <div class="homefuncbottom">COFFEE WALLET</div>
          </div>
          <div class="homefuncright">
            <van-icon class="iconfont" class-prefix="icon" name="qianbao" />
          </div>
        </div>
      </router-link>
      <router-link tag="li" to="category" class="homeFreeCoffee homefunc">
        <div class="hometext">
          <div class="homefuncleft">
            <div class="homefunctop">送Ta咖啡</div>
            <div class="homefuncbottom">SEND COFFEE</div>
          </div>
          <div class="homefuncright">
            <van-icon class="iconfont" class-prefix="icon" name="lihe" />
          </div>
        </div>
      </router-link>
      <div class="homeEnterPrise homefunc">
        <div class="hometext">
          <div class="homefuncleft">
            <div class="homefunctop">企业账户</div>
            <div class="homefuncbottom">ENTERPRISE ACCOUNT</div>
          </div>
          <div class="homefuncright">
            <van-icon class="iconfont" class-prefix="icon" name="louceng" />
          </div>
        </div>
      </div>
    </div>
    <div class="homeBottom">
      <img src="../../../assets/images/home/bottom_bar.png" class="botImg" />
    </div>
  </div>
</template>

<script>
import { getLocal } from "@/common/js/utils";
import { computed, onMounted } from "vue";
import { useRoute } from "vue-router";
import { useStore } from "vuex";
export default {
  setup() {
    const route = useRoute();
    const store = useStore();
    onMounted(() => {
      const token = getLocal("token");
      const path = route.path; // 当前页面的路由
      if (token && !["/home", "/category"].includes(path)) {
        // 已登录的情况下做页面跳转
        store.dispatch("updateCart");
      }
    });
    const count = computed(() => {
      return store.state.cartCount;
    });

    return {
      count,
    };
  },
};
</script>

<style lang="less" scoped >
a {
  color: rgb(158, 157, 158);
}
.homefunctop {
  color: #000;
}
.position {
  // position: fixed;
  display: flex;
  margin-top: 14px;
  margin-left: 30px;
  margin-bottom: 16px;
  .positionLeft {
    .locationName {
      font-size: 15px;
    }
    .distance {
      margin-left: 1px;
      font-size: 11px;
      color: #808080;
    }
  }
  .positionRight {
    position: fixed;
    display: flex;
    margin-left: 61%;
    float: right;
    width: 90px;
    height: 36px;
    border: 1px solid #88afd5;
    border-radius: 18px;
    .takingMethods1 {
      text-align: center;
      line-height: 30px;
      margin-left: 3px;
      margin-top: 3px;
      width: 44px;
      height: 30px;
      background: #88afd5;
      border-radius: 15px;
      color: #fff;
      font-size: 12px;
    }
    .takingMethods2 {
      text-align: center;
      line-height: 30px;
      margin-left: 6px;
      margin-top: 3px;
      color: #88afd5;
      font-size: 12px;
    }
  }
}
.homeFunction {
  margin-left: 20px;
  // width: 100%;
  .homefunc {
    .hometext {
      border-bottom: 1px solid #f2f2f2;

      display: flex;
      margin-top: 10px;
      margin-left: 10px;
      margin-bottom: 10px;
      height: 50px;
      .homefuncleft {
        .homefunctop {
          font-size: 16px;
          font-weight: bold;
        }
        .homefuncbottom {
          font-size: 11px;
          color: #808080;
        }
      }
      .homefuncright {
        position: absolute;
        width: 40px;
        height: 40px;
        margin-left: 74%;
        border-radius: 30px;
        border: 1px solid #63473a;
        i {
          font-size: 25px;
          top: 7px;
          left: 8px;
          margin: 0 auto;
          color: #63473a;
        }
      }
    }
  }
}
.homeBottom {
  width: 100%;
  height: 55px;

  .botImg {
    width: 87%;
    height: 55px;
    margin-left: 25px;
  }
}
</style>